1
00:00:00,240 --> 00:00:05,820
Let's do a little bit of code cleanup and error checking specifically in our session.

2
00:00:05,820 --> 00:00:08,170
Utils under server script service.

3
00:00:08,190 --> 00:00:10,680
Cast ray down for height.

4
00:00:11,430 --> 00:00:17,070
We're casting a ray down to get the height of the terrain, but we could miss the terrain specifically

5
00:00:17,070 --> 00:00:19,920
in the coins because the coins go all the way out to the edge.

6
00:00:19,920 --> 00:00:26,670
We get an edge effect and right here, if we don't get a result, we're going to return.

7
00:00:26,670 --> 00:00:31,950
A nil position will be nil when we got back from here.

8
00:00:31,950 --> 00:00:35,100
And then we'll try and add a vector to it or error.

9
00:00:35,130 --> 00:00:36,600
Then the script is going to bomb.

10
00:00:36,600 --> 00:00:37,710
We can't have that.

11
00:00:38,370 --> 00:00:38,700
All right.

12
00:00:38,700 --> 00:00:42,570
So if there is no result, let's do this else.

13
00:00:43,320 --> 00:00:44,790
Let's return a default value.

14
00:00:44,790 --> 00:00:52,650
I'm going to say return vector three dot new, x, zero and Z, and that should do it.